//
// Created by jiangpenghui on 2023/5/15.
//
#include "Obj.h"
#include "NamespaceMath.h"
#include "Integer.h"
#include "WithStatic.h"
#include "Initializer.h"
#include "Object_01.h"
#include "Base_1.h"
#include "Container_Obj.h"
#include "arr_const.h"

int main() {
    cout<<"===1==========="<<endl;
    test_local_framis();
    cout<<"====1=========="<<endl;


    cout << "main 函数执行在静态变量加载后 " << x_1 << endl;
    cout << "insdie main()" << endl;
    f();
    cout << "leaving main()" << endl;


    cout << &o << endl;

    MyLib::Obj o = MyLib::Obj("string");


    Obj b = Obj('a');

    using namespace Int;
    cout << Math::divide(Integer(1), Integer(2)).getI() << endl;

    cout << "===========================" << endl;
    cout << x << endl;

    with.print();
    with_static.print();

    cout << "===========================" << endl;


    X_static x;
    cout << "val = " << x.val() << endl;
    X_static *p_x = &x;


    p_x->f_X_static();

    cout << "val = " << x.val() << endl;

    cout << "f_X_static = " << x.f_X_static() << endl;
    cout << "val = " << p_x->incr() << endl;
    cout << "f_X_static = " << p_x->f_X_static() << endl;
    X_static::f_X_static();

    // 私有化构造函数
    // Egg egg = Egg(10);
    Egg &egg = Egg::instance();


    cout << "Egg is static add is " << &egg << endl;

    cout << "Egg  value is  " << egg.val() << endl;

    cout << "Initializer x_1 = " << init.get_x_1() << endl;

    cout << "=============Object_01=============" << endl;

    Object_01 *p_obj_01 = new Object_01(40, 'a');

    delete p_obj_01;

    void *p_obj_01_void = new Object_01(40, 'b');

    // 参数void类型对象，释放Object_01对象，而不执行该对象的析构函数，导致Object_01成员变量data空间不会被释放
    delete p_obj_01_void;

    cout << "=============Base_1.cpp=============" << endl;

    Base_1 *base_1 = new Derived_1();
    delete base_1;


    cout << "=============Base_2.cpp=============" << endl;
    Base_2 *base2 = new Derived_2();

    Derived_2 *derived_23 = static_cast<Derived_2 *>(new Base_2());

    delete base2;

    cout << "=============Dog_3.cpp=============" << endl;

    Base_1 *dog_3 = new Dog_3();
    delete dog_3;


    cout << "==========Container_Obj.cpp==========" << endl;

    Stack_Obj *stackObj;
    // 无法读取head变量
    /*  for (int i = 0; i < 10; ++i)
          stackObj->push(new Container_Obj);*/
    //  stackObj->push(new Container_Obj());

    //stackObj->push(new Container_Obj());

    cout << "=============arr_const=============" << endl;

    cout << "const_q " << const_q++ << endl;
    cout << "int_q " << int_q++ << endl;

    int_q = new int[23];


    const_q = new int[34];

    cout << "const_q " << const_q << endl;
    cout << "int_q " << int_q << endl;

    cout << x_3 << endl;

    cout << "=============auto=============" << endl;

    int count = 10;

    int *count_prt = &count;

    auto myAuto = count_prt;

    count_prt = &x_3;

    cout << "myauto " << myAuto << endl;

    cout << count << "  ";


    cout << count << endl;

    cout << "arr_const.h" << endl;

    using_d d;
    d.g('c');


    RecordType t;
    cout << "RecordType sizeof(t) " << sizeof(t) << endl;


}